using System.Collections.Generic;
using GGameFramework.Event;

namespace GGameFramework.Event
{
    public partial class EventManager
    {   
        #region EnumEventSystem 接口
        public void Register(System.Enum eventType, IEventListener listener, System.Action<int,object[]> onEvent)
        {
            mEnumEventSystem.Register(eventType, onEvent);
            TrackEnumRegistration(eventType, listener);
        }
        public void UnRegister(System.Enum eventType, System.Action<int,object[]> onEvent)
        {
            mEnumEventSystem.UnRegister(eventType, onEvent);
        }
        public void Send(System.Enum eventType, object eventData = null)
        {
            mEnumEventSystem.Send(eventType, eventData);
        }
        #endregion
        
        #region 注册跟踪
        private void TrackEnumRegistration(System.Enum eventType, object listener)
        {
            if (!mEnumListeners.ContainsKey(eventType))
                mEnumListeners[eventType] = new List<object>();
        
            if (!mEnumListeners[eventType].Contains(listener))
                mEnumListeners[eventType].Add(listener);
        }
        #endregion
    }
}

